<?php
include($folder.'/layouts/code-behind/backend.php');
if($_SESSION['id']!==null)
{
	$id = (int)$_GET['id'];
	query('DELETE FROM picture WHERE id=:id', array('id'=>$id));
	$result = queryScalar('SELECT \'failure\' FROM picture WHERE id=:id', array('id'=>$id));
	if ($result === 'failure')
	{
		$_SESSION['messageToFlash']['content'] = 'Nem sikerült törölni a képet.';
		$_SESSION['messageToFlash']['type'] = 'error';
	} else {
		$result = glob($folder.'/picture_small/'.$id.'*');
		foreach($result as $filename) unlink($filename);
		$result=glob($folder.'/picture_medium/'.$id.'*');
		foreach($result as $filename) unlink($filename);
		$result=glob($folder.'/picture_mini/'.$id.'*');
		foreach($result as $filename) unlink($filename);
		$result=glob($folder.'/picture_original/'.$id.'*');
		foreach($result as $filename) unlink($filename);
		$_SESSION['messageToFlash']['content'] = 'A kép törölve lett.';
		$_SESSION['messageToFlash']['type'] = 'information';
	}
}
header('Location: '.$prefix.'/adminisztracio/kepek');
die();
?>